Task execution device and method

ABSTRACT

A task execution method for executing a plurality of tasks while switching the tasks from one to another by time-sharing, wherein an allocated time is allocated for each of the plurality of tasks, and the plurality of tasks includes a plurality of first-type tasks and a single second-type task, and the task execution method includes a task selection step which selects a task from among the plurality of tasks according to a predetermined sequence, a correction step which corrects an allocated time for the second-type task so that execution of the plurality of tasks completes within the cycle time, when the task selected is a second-type task, which is the total allocated time for the plurality of tasks, and a task execution control step which causes the selected task to be executed so that the execution of the selected task completes within the allocated time or the corrected allocated time.

BACKGROUND OF THE INVENTION

(1) Field of the Invention

The present invention relates to a task execution device which allocatesexecution time to tasks to be executed in a Central Processing Unit(CPU), in other words, relates to an Operating System (OS).

(2) Description of the Related Art

The main functions of the OS are “hardware management”, “taskmanagement”, “data management” and “input/output management”. Above all,“task management” refers to the management of the task executionsequence, and is an important function for making a CPU, a memory, aninput/output device, and so on, operate effectively. Here, a “task” is aunit of control which manages a series of flows, such as the start-up,execution and completion of a program, as a batch. A program whichoperates under the OS's management is handled as a task. The tasks inevery OS operation related to the execution of a program are performedas units.

The time-sharing scheduling method is well-known as an example of analgorithm which determines a task execution sequence. The time-sharingscheduling method is a task scheduling method which allocates anexecution time for each task, applies the allocated times to tasks inthe CPU which have execution permission, and when the times allocatedfor the tasks elapse, transfers execution permission to other tasks. Bydoing so, execution permission is assigned for every task by an equaland determined time.

There are methods for the determination of the allocated time such as amethod of fixed allocation according to a task's properties, and amethod of dynamic determination according to the task's executionconditions, and for instance, methods such as adjusting the allocatedtime for the execution permission, based on task priority, are wellknown (see for example, Japanese Laid-Open Patent Application No.2005-18560 Publication).

However, in the case where a task is shifted to a waiting state when itmust wait for an event, conventional OSs will transfer executionpermission to a subsequent task, or execute no processes until theallocated time has expired for the task shifted to the waiting state.Also, in an execution environment where tasks which need a guarantee ofprocess performance, and tasks for which processes are generatedasynchronously, such as an event driven process, co-exist, asynchronousprocesses must be executed while continuously distributing processperformance and maintaining the cycle for the entire process ismaintained. As a result there are the problems that overhead occurs, andprocessing power drops due to the continuous adjustment and execution ofthe allocated time.

SUMMARY OF THE INVENTION

The present invention is conceived in order to achieve the objectsabove, and aims to provide a task execution device and method which canreduce a load accompanying the allocated adjustments for the allocatedtime of a task while preserving a fixed processing power.

In order to achieve the objects above, the task execution device in thepresent invention is a task execution device for executing a pluralityof tasks while switching the tasks from one to another by time-sharing,wherein an allocated time is allocated for each of the plurality oftasks, and the plurality of tasks includes a plurality of first-typetasks and a single second-type task. The task execution deviceincluding: a cycle time storage unit which stores a cycle time, which isa total time of the allocated times for the plurality of tasks; a taskselection unit which selects a task from among the plurality of tasksaccording to a predetermined sequence; a correction unit which, when theselected task is the second-type task, corrects an allocated time forthe selected second-type task so that execution of the plurality oftasks completes within the cycle time; and a task execution control unitwhich causes the selected task to be executed so that execution of thetask completes within one of the allocated time and the correctedallocated time.

According to this configuration, the tasks which are executed in theprocessor are divided into first-type tasks and a second-type task, andcorrections to the allocated time are performed for only the second-typetask, such that the plurality of tasks are executed within the cycletime. As a result, while a fixed processing power is preserved, a taskscheduling device can be provided which can reduce the load accompanyingthe allocated adjustments for the task execution time. Note thatcorrections to the allocated time for the second type task do not haveto be performed in the case where all of the first type tasks areshifted into a waiting state.

Preferably the allocated time for the second-type task is one of a firstallocated time, which is the minimum time which must be executed for theexecution time of the task, and a second allocated time, which is a sumof a predetermined margin time and the first allocated time, and thecorrection unit further includes: a total consumed time calculation unitwhich calculates a total consumed time consumed in the execution of theplurality of first-type tasks; and an allocated time correction unitwhich corrects the allocated time for the second-type by subtractingfrom the margin time a difference between the total consumed time andthe total allocated time for the plurality of first-type tasks, and byadding the result of the subtraction to the first allocated time. Morespecifically, in the case where the difference between the totalconsumed time and the total allocated time for the second-type task islarger than the margin time, the allocated time correction unit whichcorrects the allocated time by adding a time, which is a result ofsubtracting the margin time from the difference between the totalconsumed time and the total allocated time, to the first allocated timefor a second-type task to be executed in a subsequent cycle, so that aresult of the addition does not exceed the cycle time where the cycle isan interval during which each of the plurality of tasks are executedonce.

By assuming a configuration like this, the first allocated time isreserved for the second-type task and the second-type task can bereliably executed.

Preferably, the task execution device mentioned above further includes apower supply reduction unit which reduces supply of electric power to aprocessor in which the second-type task is executed, during theallocated time for the second type task, in the case where thesecond-type task is shifted into a waiting state. In addition, the taskexecution device mentioned above further includes a power supplystopping unit which stops supply of electric power to a processor inwhich the plurality of tasks is executed, in the case where all of theplurality of tasks is shifted into a waiting state.

The execution situation of each task is detected, and by changing thetask to a state of providing power to the processor, the power that mustbe consumed for the execution of the task can be reduced.

Note that the present invention may be realized not only as the taskexecution device above but also as a task execution method whichincludes the characteristic units included in the task execution deviceas steps, and as an operating system for causing a computer to executethese steps. It goes without saying that this sort of program can bedistributed through a recording medium such as a CD-ROM and atransmission medium such as the Internet.

According to the present invention, a task scheduling device can beprovided which can reduce the load accompanying the allocatedadjustments for the task execution time while preserving a fixedprocessing power.

FURTHER INFORMATION ABOUT TECHNICAL BACKGROUND TO THIS APPLICATION

The disclosure of Japanese Patent Application No. 2005-243417 filed onAug. 24, 2005 including specification, drawings and claims isincorporated herein by reference in its entirety.

BRIEF DESCRIPTION OF THE DRAWINGS

These and other objects, advantages and features of the invention willbecome apparent from the following description thereof taken inconjunction with the accompanying drawings that illustrate a specificembodiment of the invention. In the Drawings:

FIG. 1 is a block diagram which shows the structure of the principalpart of a task execution device which switches time slots in theembodiment of the present invention;

FIG. 2 is a diagram which shows specific examples of time slot data in atime slot storage unit, and task management blocks in a task storageunit;

FIG. 3 is a diagram which describes the manner of task switchingperformed by a time slot switching unit and a task selection unit;

FIG. 4 is a flowchart of the scheduling process performed by a taskscheduling unit;

FIG. 5 is a flowchart of the process for calculating the allocated timeby the task scheduling unit to time slots for event driven tasks; and

FIG. 6 is a flowchart of the process for calculating the allocated timefor the time slots for event driven tasks by the task scheduling unit.

DESCRIPTION OF THE PREFERRED EMBODIMENT(S) Overall Structure

FIG. 1 is a block diagram which shows a structure of the principal partof a task execution device which switches tasks in the embodiment of thepresent invention. In the figure is shown a typical functions realizedby executing software which switches tasks as a function of a part ofthe OS in a processor. The hardware structure of the processor may be astandard structure.

The task execution device is configured to handle every plurality oftasks which have an “allocated time” designation in one processor, andto execute the program while maintaining the performance necessary foreach task.

The task execution device is configured, as shown in the figure, from atask scheduling unit 10, a program storage unit 20, a timer control unit30 and an execution control unit 40.

The task scheduling unit 10 allocates a time-slot to each task which hasan “allocated time” designation and performs time division scheduling,which selects each task at least once within a cycle that has beendesignated in advance. Here, the “time slot” is a slot delimited by theprogram execution time in the processor for every allocated time withina cycle T, which has been predetermined.

The program storage unit 20 stores the program, which is a concatenationof tasks, and which is targeted for scheduling by the task schedulingunit 10, and also stores data related to the program.

The timer control unit 30 starts a time count for each allocated timeset by the task scheduling unit 10, and outputs a time-out signal whenthe allocated time has been reached. This time-out signal notifies thetask scheduling unit 10 of the timing for the time slot's switching.

The execution control unit 40 executes a task selected by the taskscheduling unit 10. The execution control unit 40 corresponds to thehardware which executes the task, such as a CPU.

(Configuration of task scheduling unit 10)

The task scheduling unit 10 is configured from a task acceptance unit11, a time slot storage unit 12, a task storage unit 13, a time slotswitching unit 14 and a task selection unit 15.

<1. Task acceptance unit 11>

The task acceptance unit 11 accepts a task addition request according toan instruction from a user operation, a user program and so on, andreads out “task data” and “allocated time” from the program storage unit20 as data related to the task. In addition, the task acceptance unit 11generates a time slot data 100 (110) and a task management block 200(210) from the task data and the allocated time so that the task istargeted for scheduling, and configures the time slot data 100 (110) andthe task management block 200 (210) in the time slot storage unit 12 andthe task storage unit 13, respectively.

Here, “task data” includes a “program start address” and a “stackpointer”. The “program start address” is the initial address into whichthe task is written. The “stack pointer” is position data which showsthe holding location, which temporarily saves the task state when taskswitching has occurred.

The tasks are assigned in one to one correspondence with a time slot bythe task scheduling unit 10, and are executed securely within theallocated times of the time slot.

The tasks are classified into two types, according to their executionproperties (type A and type B). Tasks which need a fixed processperformance are included under “type A”. Tasks which are calledtime-driven tasks should be included under type A. For example, it ispreferable to include a task under type A which requires a constantprocess performance and maintains a decoding and encoding process forvideo data and a decoding and encoding process for audio.

On the other hand, tasks which do not need a constant processperformance are included under “type B”. Tasks which are calledevent-driven tasks should be included in type B. For example, taskswhich maintain and do not need a constant process performance, but occurirregularly and occasionally, such as a process which carries out a menudisplay, of text and still images, displaying a user's operation as anevent, are preferably included under type B.

The “allocated time” is a value which designates the allocated time forthe time-slot which corresponds to the task. This allocated time is atime designated by the program.

Note that the total allocated time for the tasks executed in one cycleis held in a cycle resistor 16 as the cycle T.

<2. Time-slot storage unit 12>

The time-slot storage unit 12 stores time slot data for generating timeslots, which serve as the basis for task switching.

FIG. 2 is a diagram which shows a specific example of time slot data inthe time slot storage unit 12, and task management blocks in the taskstorage unit 13. As shown in the figure, the time slot storage unit 12stores a plurality of time slot data 100, 110, . . . 120, 130. The timeslot data from 100 to 120 indicate time slots to which type A tasks havebeen assigned. Additionally, the remaining time slot data 130 indicatesa time slot to which a type B task has been assigned.

The time slot data 100 corresponds to one time slot and is made up of anallocated time 100 a, an execution flag 100 b and a pointer 100 c; thisis the same for other time slot data.

The allocated time 100 a indicates a time in which a task correspondingto a time slot can be executed. When the time that the task has actuallytaken to execute reaches the allocated time, the task corresponding tothe subsequent time slot is executed. The allocated times from 100 a to120 a, which correspond to type A tasks, are set respectively by timercontrol unit 30, at the same time that the time slot data from 100 to120 are generated. The allocated time 130 a, which corresponds to aplurality of type B tasks is assumed to be the remaining time aftersubtracting the total of the allocated times for the other time slotsfrom 100 a to 120 a from a time T of one cycle, held in the cycleresistor 16. This remaining time is a value that changes according tothe task scheduling. Note that the calculation method for the allocatedtime 130 a is an example, and other calculation methods are elaboratedbelow.

The “execution flag” indicates whether the time slot is valid orinvalid. The execution flag is set as valid when the time slot data isgenerated, is set as invalid when the resources of the accessdestination enter a locked state during the execution of the task andthe task has entered a waiting state; afterwards, the execution flag isset as valid when the task returns from the waiting state to theexecution permitted state. When the execution flag indicates that it isinvalid, the time slot data from the time slot switching unit 14 regardsthe execution flag as not existing.

The “pointer” indicates a task management block which corresponds to thetime slot. These time slot data 100, 110, 120, 130 compose an array, andthe sequence of this array expresses the generation sequence for thetime slots.

<3. Task storage unit 13>

The task storage unit 13 stores the task management blocks 200, 210, . .. , 220 and 230, which correspond to the tasks assigned to the timeslots. The task management blocks 200, 210, . . . , 220 and 230correspond to each task respectively, and are data for managing thetasks.

The task management block 200 is made with the task data 200 a. The taskdata 200 a includes a program start address (or an address at whichexecute of a program resumes) and a stack pointer. When the taskmanagement block 200 is generated, the task data 200 a is the task dataitself inputted by the task acceptance unit 11. When switching tasks,the task data 200 a indicates the execution address and the value of thestack pointer at the point in time at which a task has been interrupted.

<4. Time slot switching unit 14>

The time slot switching unit 14 performs time slot switching when theexecution time for a task in the present time slot has reached theallocated time. The timer control unit 30 notifies the time slotswitching unit 14, by a time-out signal, whether or not the allocatedtime has been reached. The time slot switching unit 14 which hasreceived the notification selects the subsequent time slot data.

In the present embodiment, the subsequent time slot data is selectedaccording to the sequence of time slot data in the array. In otherwords, the time slot data is selected in the sequence of the time slotdata 100, 110, . . . , 120, 130, and after the last time slot data 130is selected, it is assumed that the first time slot data 100 isre-selected.

The time slot switching unit 14 acquires the allocated time from thetime slot data selected, and sets this in the timer control unit 30. Bydoing so, a time count for the allocated time for the subsequent timeslot is started.

<5. Task selection unit 15>

The task selection unit 15 saves the execution address, the stackpointer and so on for the program that is currently being executed, astask data, into the task's task management block, when the time slot hasbeen switched by the time slot switching unit 14, or when there has beenan instruction from the program that is currently being executed. Thetask selection unit 15 extracts task data from the task management blockof the task which must be executed subsequently and outputs the taskdata to the execution control unit 40. Simultaneously, the taskselection unit 15 saves the context (resistor data, and so on) of thetask currently being executed and resets the context of the task whichmust be executed subsequently. By doing so, the task which must beexecuted subsequently enters an execution state.

FIG. 3 is an explanatory diagram which shows a description of the taskswitching performed by the time slot switching unit 14 and the taskselection unit 15.

In the figure, the cycle T indicates a cycle that is held by the cycleresistor 16. The time slots from t1 to tn correspond to n time slot data100, 110, . . . , 120, which in turn correspond to n type A tasks, andthe length (from t1 to tn) indicates the allocated time for n tasksrespectively. Additionally, t0 is a time slot which corresponds to thetime slot data 130, which in turn corresponds to a type B task, and thelength (t0) indicates the type B task's allocated time.

S indicates the scheduling process in which task switching is performedby the time slot switching unit 14 and the task selection unit 15.

In the figure, the type A task A1 which corresponds to the time slotdata 100 is selected and executed in the scheduling process S when thetime slot t1 is started. Type A tasks are executed in the same way forany of the time slots from t2 to tn. Also, a type B task is selected andexecuted in the scheduling process S for the final time slot t0. In thisway, each task will definitely be executed at least once within onecycle T. In addition, a type B task B will be executed only once withinone cycle T.

Details of the Process

Below, the scheduling process executed by the task execution device inthe present embodiment is described.

<1. Scheduling process>

The scheduling process is described based on the flowchart in FIG. 4.When the time set by the timer control unit 30 elapses, a time-outsignal is transmitted to the time slot switching unit 14 and thescheduling process starts. First, the task state currently beingexecuted is saved in the task data (S301). Next, the time slot switchingunit 14 performs a time slot selection process (S302). In other words,the content following the content currently selected in the time slotdata array becomes the time slot data to be subsequently selected. Inthe case where there is not a subsequent content, the initial content inthe time slot data array is selected. In other words, the time slotswitching unit 14 performs selection sequentially from the time slotdata 100 of the time slot t1 to the time slot data 130 of the time slott0, and afterwards performs selection again sequentially, starting fromthe time slot data 100 of the time slot t1.

The handling of the allocated time and the operations differ when thetask in the time slot is invalid, or in a waiting state, according towhether or not the time slot t0 be subsequently selected is the timeslot t0 (S303).

In the case where a time slot other than the time slot t0 has beenselected (No in S303), the time slot switching unit 14 extracts theallocated time included in the time slot data of the selected time slotand outputs this allocated time to the timer control unit 30 (S304).After a time has elapsed from this point in time equal to the allocatedtime, a time-out signal is transmitted again from the timer control unit30.

When an execution flag, held by the time slot data of the selected timeslot, is invalid (No in S305), this indicates that there is no task tobe executed, or the task is in a waiting state. As a result, the timeslot switching unit 14 switches the time slot t0 the subsequent timeslot and performs the same process until a valid time slot is found.

If there is a valid time slot (Yes in S305), the task selection unit 15resets the state of the interrupted task corresponding to the time slot,and the execution control unit 40 resumes the execution of the task(S306).

When the time slot switching unit 14 selects the time slot t0 (Yes inS303), the time slot switching unit 14 begins by calculating theallocated time for the time slot t0 (S307). Since the process covers abroad spectrum, the details are described afterward. The time slotswitching unit 14 outputs the allocated time calculated in the processto the timer control unit 30 (S308).

When the execution flag held by the time slot is valid (Yes in S309), inthe same way as above when the time slot selected is a time slot otherthan t0, the task selection unit 15 resets the state of the interruptedtask corresponding to the time slot t0, and the execution control unit40 resumes the task (S306).

When the execution flag held by the time slot is invalid (No in S309),the time slot switching unit 14 checks to see whether all of theexecution flags in the time slots other than the time slot t0 areinvalid (S310). When all of the execution flags are invalid (Yes inS310), the task selection unit 15 shifts the CPU into a stopped statesince there is not a valid execution process for every task in the timeslot. In order to perform a reset from the stopped state, an outsidesignal such as an interrupt is used.

If there is even one valid time slot (No in S310), the CPU is made tooperate, however since there is no need to make the CPU operate duringthe allocated time for the time slot t0, the CPU is shifted into apower-saving state.

<2. Process for calculating the allocated time for the time slot t0>

Next, the process for calculating the allocated time for the time slott0 (S307 in FIG. 4) is described based on the flowcharts in FIG. 5 andFIG. 6. There are three variations to the process which are describedrespectively.

(a) Case where the allocated time for a time slot in the waiting stateis allocated for the time slot t0

As shown in FIG. 5, the total time consumed in the execution of tasks ina previous cycle (total time consumed) and the total allocated time forthe time slots with invalid execution flags (non-execution time) arecalculated for the time slots from the time slot t1 to tn (from S401 toS404).

When the total consumed time is larger than the total allocated time forthe time slots from t1 to tn, the influence of an external cause such asan interruption is interpreted to be the cause. Because of this, theresult of (total consumed time—total allocated time) is subtracted fromthe total allocated time for the time slots with invalid executionflags, i.e. from the non-execution time. In other words, the result of(total consumed time—total allocated time), which is the time exceededon account of an external cause, is subtracted from the time in whichthe task assigned for the time slot is not being executed (non-executiontime).

Adding the allocated time for the time slot t0 to this value gives theallocated time for the time slot t0 after calculation (S406).

Note that even if the total consumed time is smaller than the totalallocated time, the allocated time for the time slot t0 can becalculated by using the same equation.

(b) Case where the margin time is set, and from it is decremented theportion of consumed time exceeding the allocated time

As shown in FIG. 6, a margin value 17 is set in advance by the taskacceptance unit 11 and the value is acquired from the acceptance unit 11(S411). The margin value 17 is a margin time (margin time) M, allocatedto the allocated time for the time slot t0. In other words, there areassumed to be two stages for the allocated time for the time slot t0, t0and (t0+M).

First, the total for the time consumed in execution for a previous cycle(total consumed time) is calculated for the time slots from t1 to tn(S412, S413).

Next, when the total consumed time is more than the total allocatedtime, the result of (total consumed time—total allocated time) issubtracted from the margin time M (S414). Here, the total allocated timerefers to the total allocated time for the time slots from t1 to tn.

The time result after adding the allocated time for the time slot t0 tothe value after subtraction gives the allocated time after calculationfor the time slot t0 (S415).

Note that when the margin M<the result of (total consumed time−totalallocated time), in other words, when the value sought at S414 isnegative, the margin time M is set to 0 and the result of ((totalconsumed time−total allocated time)−the margin M) is time-adjusted forexecution in the time slot t0 of the subsequent cycle. This way, thetasks can be executed while keeping the allocated time for the time slott0 in this cycle T.

(c) Instead of the margin value, the value given by acquiring a cycle 15from the task acceptance unit 11, and subtracting the total consumedtime from the cycle T (the total allocated time), may be set as theallocated time for the time slot t0 after calculation.

As described above, according to the task execution device in thepresent embodiment, performance can be retained by calculating andsetting only the allocated time for a particular time slot, withoutre-calculating the allocated time for another time slot. As a result, itbecomes possible to reduce the overhead necessary for re-setting theallocated time in the case where the situation has changed.

Also, by detecting the execution situation of the time slot and changingthe CPU state, the present invention can contribute to reducingelectricity consumption related to program execution.

Note that in the above embodiment, the case was described where oneallocated time was designated for every task data as a fixed value forthe time slots with type A tasks, however the task execution device maybe realized as a configuration in which the task execution deviceretains two fixed values which indicate the largest and smallest valuesof the allocated times for every time slot, takes the total of thelargest values of the allocated times for all of the time slots as acycle, and operates while each time slot selects one of the allocatedtimes according to the execution situation.

In addition, in the case where it is detected that the smallest value isselected in each time slot, the process will conclude in a short amountof time. Because of this, the operation frequency of the CPU may belowered in order to execute a task within a range before one cycle'sworth of process concludes in the set cycle T. As a result, it ispossible to further contribute to a reduction in electricity consumptionnecessary for the execution of the task. Note that it is determined on aprogram, whether the largest values or the smallest values of theallocated times are used.

INDUSTRIAL APPLICABILITY

The task execution device in the present invention has (a) function(s)for adjusting all of the allocated time by time allocation which doesnot depend on process performance, while performing a fixed timeallocation which ensures process performance. Because of this, it ispossible to reduce the process load in allocated time adjustment forprocesses which ensure process performance; for example imagereproduction processes can be carried out without being affected bynoise or disturbance of image output caused by access from outside. Inparticular, the present invention can be applied as a device whichperforms audio/visual processes and non-synchronous control processes inreal-time, as well as a development environment for such a device.

1. A task execution device for executing a plurality of tasks whileswitching the tasks from one to another by time-sharing, wherein anallocated time is allocated for each of the plurality of tasks, theplurality of tasks includes a plurality of first-type tasks and a singlesecond-type task, and said task execution device comprises: a cycle timestorage unit operable to store a cycle time, which is a total time ofthe allocated times for the plurality of tasks; a task selection unitoperable to select a task from among the plurality of tasks according toa predetermined sequence; a correction unit operable to, when theselected task is the second-type task, correct an allocated time for theselected second-type task so that execution of the plurality of taskscompletes within the cycle time; and a task execution control unitoperable to cause the selected task to be executed so that execution ofthe task completes within one of the allocated time and the correctedallocated time.
 2. The task execution device according to claim 1,wherein said correction unit is operable to correct the allocated timeby adding a non-execution time to the allocated time for the second-typetask, the non-execution time being a total allocated time for tasksamong the plurality of first-type tasks which did not enter an executionstate.
 3. The task execution device according to claim 2, wherein saidcorrection unit includes: a total consumed time calculation unitoperable to calculate a total consumed time consumed in the execution ofthe plurality of first-type tasks; a non-execution time calculation unitoperable to calculate the non-execution time, which is the totalallocated time for the tasks among the first-type tasks which did notenter the execution state; and an allocated time correction unitoperable to correct the allocated time for the second-type task bysubtracting from the non-execution time a difference between the totalconsumed time and the total allocated time for the plurality offirst-type tasks, and by adding a result of the subtraction to theallocated time for the second-type task.
 4. The task execution deviceaccording to claim 1, wherein said correction unit is operable to set adifference between the cycle time and the total consumed time as theallocated time for the second-type task, the total consumed time beingconsumed in the execution of the plurality of first-type tasks.
 5. Thetask execution device according to claim 1, wherein the allocated timefor the second-type task is one of a first allocated time, which is theminimum time which must be executed for the execution time of the task,and a second allocated time, which is a sum of a predetermined margintime and the first allocated time, and said correction unit furtherincludes: a total consumed time calculation unit operable to calculate atotal consumed time consumed in the execution of the plurality offirst-type tasks; and an allocated time correction unit operable tocorrect the allocated time for the second-type by subtracting from themargin time a difference between the total consumed time and the totalallocated time for the plurality of first-type tasks, and by adding theresult of the subtraction to the first allocated time.
 6. The taskexecution device according to claim 5, wherein in the case where thedifference between the total consumed time and the total allocated timeis larger than the margin time, said allocated time correction unit isoperable to correct the allocated time for the second-type task byadding a time, which is a result of subtracting the margin time from thedifference between the total consumed time and the total allocated time,to the first allocated time for a second-type task to be executed in asubsequent cycle, so that a result of the addition does not exceed thecycle time where the cycle is an interval during which each of theplurality of tasks are executed once.
 7. The task execution deviceaccording to claim 1, further comprising, a power supply reduction unitoperable to reduce the supply of electric power to a processor in whichthe second-type task is executed, during the allocated time for thesecond type task, in the case where the second-type task is shifted intoa waiting state.
 8. The task execution device according to claim 1,further comprising, a power supply stopping unit operable to stop supplyof electric power to a processor in which the plurality of tasks isexecuted, in the case where all of the plurality of tasks is shiftedinto a waiting state.
 9. The task execution device according to claim 1,wherein a maximum value and a minimum value are set in the allocatedtime for each of the plurality of tasks, said cycle time storage unitstores a cycle time, which is a total time of the maximum values of theallocated times for the plurality of tasks, and said task executioncontrol unit is operable to control in such a way that each of theplurality of first-type tasks completes execution within one of themaximum value and the minimum value of the allocated time for each ofthe plurality of first type tasks.
 10. The task execution deviceaccording to claim 9, wherein said task execution control unit isoperable to lower an operation frequency of a processor in which each ofthe plurality of first-type tasks is executed, when a scheduling isperformed so that each of the plurality of first-type tasks completesexecution within the minimum value of the allocated time for each taskof the plurality of first type tasks.
 11. A task execution method forexecuting a plurality of tasks while switching the tasks from one toanother by time-sharing, wherein an allocated time is allocated for eachof the plurality of tasks, and the plurality of tasks includes aplurality of first-type tasks and a single second-type task, said taskexecution method comprising: selecting a task, from among the pluralityof tasks, according to a predetermined sequence; correcting theallocated time for a selected second-type task so that the execution ofthe plurality of tasks completes within the cycle time, when theselected task is the second-type task; and causing the selected task tobe executed so that execution of the selected task completes within oneof the allocated time and the corrected allocated time.
 12. An operatingsystem for executing a plurality of tasks while switching the tasks fromone to another by time-sharing, wherein an allocated time is allocatedfor each of the plurality of tasks, and the plurality of tasks includesa plurality of first-type tasks and a single second-type task, saidoperating system causing a computer to execute: selecting a task, fromamong the plurality of tasks, according to a predetermined sequence;correcting the allocated time for a selected second-type task so thatthe execution of the plurality of tasks completes within the cycle time,when the selected task is the second-type task; and causing the selectedtask to be executed so that execution of the selected task completeswithin one of the allocated time and the corrected allocated time.